package org.springblade.modules.notice.utils;

import org.springblade.modules.repair.enums.CompanyCategoryEnum;
import org.springblade.modules.notice.enums.ChannelType;
import org.springblade.modules.notice.enums.IdType;

/**
 * @Author ysq
 * @Date 2024/11/29
 * @Description 推送id类型工具类
 */
public class PushIdTypeUtil {

	/**
	 * 获取推送id字段名
	 * @param channelTypeCode
	 * @param clientType 当公众号时，1-维保公众号，2-物业公众号
	 * @return
	 */
	public static String getPushIdField(Integer channelTypeCode, Integer clientType) {
		if (ChannelType.SMS.getCode().equals(channelTypeCode) || ChannelType.VOICE.getCode().equals(channelTypeCode) || ChannelType.IVR_VOICE.getCode().equals(channelTypeCode)){
			return IdType.PHONE.getField();
		} else if (ChannelType.PUSH.getCode().equals(channelTypeCode)) {
			return IdType.RID.getField();
		} else if (ChannelType.TWY_SYSTEM.getCode().equals(channelTypeCode)) {
			return IdType.USER_ID.getField();
		} else if (ChannelType.OFFICIAL_ACCOUNT.getCode().equals(channelTypeCode)) {
			if (CompanyCategoryEnum.MAINTAIN_COMPANY.getId() == clientType) {
				return IdType.OPEN_ID.getField();
			} else if (CompanyCategoryEnum.ESTATE_COMPANY.getId() == clientType) {
				return IdType.ESTATE_OPEN_ID.getField();
			} else {
				return null;
			}
		}
		return null;
	}
}
